//
//  BukaMediaManager.h
//  BukaSDKFoundation
//
//  Created by 曹飞 on 2018/3/4.
//  Copyright © 2018年 tv.buka. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <BukaSDK4IOS/BukaSDK.h>

#import "BukaStatus.h"

typedef void(^BukaMediaManagerOutAveAlarmLog)(int level ,int error_code,NSString * error_log,int log_len );


typedef void(^BukaMediaManagerOnRtcpStatus)(unsigned int streamId,int packetNum, unsigned int cumulativeLost, unsigned int fractionLost,unsigned int jitter, bool upload);

typedef void(^BukaMediaManagerOutAveLocalVolume)(BukaStatus * statu ,unsigned int level);

typedef void(^BukaMediaManagerOutAveRemoteVolume)(Stream * stream,unsigned int level);

typedef void(^BukaMediaManagerOutAveBand)(long sendBandwidth,long recvBandwidth);

typedef void(^BukaMediaManagerOutAveRemoteYuv)(NSData* data,int len,int streamid,int width,int height);

typedef void(^BukaMediaManagerOutAveLocalYuv)(NSData* data,int len,int streamid,int width,int height);

typedef void(^BukaMediaManagerInAveLocalYuv)(NSData* data,int len,int streamid,int width,int height);

typedef void(^BukaMediaManagerOutAveLocalPcm)(NSData* data,int len,int channel ,int sample_rate_hz);

typedef void(^BukaMediaManagerOutAveRemotePcm)(NSData* data,int len,int channel ,int sample_rate_hz);

typedef void(^BukaMediaManagerOutAveStreamBand)(long streamid,long recv_bandwidth);

typedef void(^BukaMediaManagerOutRTSPPCM)(NSData* data,int len);

typedef void(^BukaMediaManagerOnAveRTSPDisconnetEvent)(long streamid,int error);

typedef void(^BukaMediaManagerOutPrint)(int level,NSString * message,int length);



@interface BukaMediaManager : NSObject


@property (nonatomic,copy) BukaMediaManagerOutAveAlarmLog outAveAlarmLogBlock;

@property (nonatomic,copy) BukaMediaManagerOnRtcpStatus onRtcpStatusBlock;

@property (nonatomic,copy) BukaMediaManagerOutAveLocalVolume outAveLocalVolumeBlock;

@property (nonatomic,copy) BukaMediaManagerOutAveRemoteVolume outAveRemoteVolumeBlock;

@property (nonatomic,copy) BukaMediaManagerOutAveBand outAveBandBlock;

@property (nonatomic,copy) BukaMediaManagerOutAveRemoteYuv outAveRemoteYuvBlock;

@property (nonatomic,copy) BukaMediaManagerOutAveLocalYuv outAveLocalYuvBlock;//废弃

@property (nonatomic,copy) BukaMediaManagerInAveLocalYuv inAveLocalYuvBlock; //废弃

@property (nonatomic,copy) BukaMediaManagerOutAveLocalPcm outAveLocalPcmBlock;//废弃

@property (nonatomic,copy) BukaMediaManagerOutAveRemotePcm outAveRemotePcmBlock;//废弃

@property (nonatomic,copy) BukaMediaManagerOutAveStreamBand outAveStreamBandBlock;

@property (nonatomic,copy) BukaMediaManagerOutRTSPPCM outRTSPPCMBlock;//废弃

@property (nonatomic,copy) BukaMediaManagerOnAveRTSPDisconnetEvent onAveRTSPDisconnetEventBlock;

@property (nonatomic,copy) BukaMediaManagerOutPrint outPrintBlock;




+ (instancetype)sharedInstance;


/**
 推流

 @param roomID 房间id
 @param receiptDelegate 发布状态回调
 */
-(void)publishStreamWith:(NSString*)roomID
     withReceiptDelegate:(id<ReceiptDelegate>)receiptDelegate;


/**
 推流

 @param roomID 房间id
 @param width 分辨率宽 16:9
 @param height 分辨率高 16:9
 @param receiptDelegate 发布状态回调
 */
-(void)publishStreamWith:(NSString*)roomID
               withWidth:(int)width
              withHeight:(int)height
     withReceiptDelegate:(id<ReceiptDelegate>)receiptDelegate;


/**
 推流

 @param roomID 房间id
 @param width 分辨率宽 16:9
 @param height 分辨率高 16:9
 @param hasAudio 是否有音频
 @param hasVideo 是否有视频
 @param cameraid 0前置摄像头，1后置摄像头
 @param maxBitrate 500
 @param maxFramerate 10
 @param receiptDelegate 发布状态回调
 */
-(void)publishStreamWith:(NSString*)roomID
               withWidth:(int)width
              withHeight:(int)height
               withAudio:(BOOL)hasAudio
               withVideo:(BOOL)hasVideo
            withCameraId:(int)cameraid
          withMaxBitrate:(int)maxBitrate
        withMaxFramerate:(int)maxFramerate
     withReceiptDelegate:(id<ReceiptDelegate>)receiptDelegate;

/**
 断线重连后，如果正在发布，需要想服务器重新添加状态，不要重新发布，执行这个方法就可以了
 */
-(void)reConnectPublish:(id<ReceiptDelegate>)receiptDelegate;

/**
 * 是否正在发流
 */
-(BOOL)isPublish;

-(BukaStatus *)getPublishStatus;

/**
 停止发布

 @param receiptDelegate 状态回调
 */
-(void)stopPulish:(id<ReceiptDelegate>)receiptDelegate;


/**
 拉流

 @param stream 流业务实体
 @param receiptDelegate 状态回调
 */
-(void)playStream:(BukaStatus*)stream withReceiptDelegate:(id<ReceiptDelegate>)receiptDelegate;

/**
 拉流

 @param stream 流业务实体
 @param hasVideo 是否有视频   hasVideo hasAudio 不能同时为NO
 @param hasAudio 是否有声音   hasVideo hasAudio 不能同时为NO
 @param receiptDelegate 状态回调
 */
-(void)playStream:(BukaStatus*)stream  hasVideo:(BOOL)hasVideo hasAudio:(BOOL)hasAudio withReceiptDelegate:(id<ReceiptDelegate>)receiptDelegate;


/**
 停止播放某一路流

 @param stream 流业务实体
 @param receiptDelegate 状态回调
 */
-(void)stopPlay:(BukaStatus*)stream receiptDelegate:(id<ReceiptDelegate>)receiptDelegate;


/**
 停止所有正在本地播放的流
 */
-(void)stopAllStream;

/**
 某一路流是否正在播放

 @param stream 流业务实体
 @return YES 正在播放 NO 没播放
 */
-(BOOL)isPlay:(BukaStatus*)stream;


/**
 * 停止推流音频
 *
 * @return 停止成功
 */
-(BOOL)stopPublishAudio;

/**
 * 恢复推流音频
 *
 * @return 恢复成功
 */
-(BOOL)resumePublishAudio;

/**
 * 停止推流视频
 *
 * @return 停止成功
 */
-(BOOL)stopPublishVideo;

/**
 * 恢复推流视频
 *
 * @return 恢复成功
 */
-(BOOL)resumePublishVideo;


/**
 切换摄像头
 */
-(void)switchCamera;


/**
 是否开启mic输入 本地静音用

 @param enable NO 打开 YES关闭
 */
-(void)enableMicMute:(BOOL)enable;

/**
 获取当前房间所有流相关的Stream
 
 @return Stream 数据列表
 */
-(NSArray <BukaStatus*> *)getStreamArr;



/**
 获取本地正在发布的流数据
 
 @return key value
 */
-(NSArray*)publishingStream;

/**
 获取本地正在播放的流数据
 
 @return key value
 */
-(NSArray*)playingStreams;



/**
 旋转发布流渲染角度
 
 @param rotate 0 90 180 270
 */
-(void)changePublisRotateCapturedFramesRotate:(int)rotate; //NS_DEPRECATED_IOS(2_0, 2_0, "废弃");



-(void)aveStop;


@end
